package com.config;

import com.utils.JDBCUtils;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

@Configuration
@ComponentScan("com")
public class AppConfig {

    //有一些bean我们是不方便/没有必要加
    // @Repository、@Service、@Component

    //数据库连接
    @Bean //这时候将Connection连接放入到Spring bean缓存中

    public Connection getConn(){
        try(Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306","root","root")) {
            return conn;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }



}
